﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MMITDomain.Abstract;
using MMITDomain.Entities;

namespace MMITWeb.Areas.Teller.Controllers
{
    public class SetupsController : Controller
    {
        private ICountryRepository _countryRepository;

        public SetupsController(ICountryRepository countryRepository)
        {
            _countryRepository = countryRepository;
        }

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Countries(int? Id)
        {
            if (!Id.HasValue)
            {
                var countries = _countryRepository.Countries;
                return View(countries);
            }
            else
            {
                var country = _countryRepository.GetCountryById(Id.Value);
                return View("EditCountry",country);
            }

        }

        public ActionResult AddCountry()
        {
            return View();
        }

        [HttpPost]
        public ActionResult AddCountry(Country model)
        {
            if (ModelState.IsValid)
            {
                _countryRepository.SaveCountry(model);
            }
            return View();
        }

    }
}
